package com.cn.springcloudwechat.model.enumerate;

/**
*@program: YmArticleType
*@author: Administrator
*@create: 2018-07-18 10:17
*/
public enum  YmArticleType {
    /**
     * 热门文章
     */
    HOTARTICLES(1,"热门"),
    /**
     * 精选文章
     */
    FEATUREDARTICLES(2,"精选"),
    /**
     * 推荐文章
     */
    RECOMMENDEDARTICLES(3,"推荐"),
    /**
     * 最新文章
     */
    NEWEST(4,"最新");

    private int key;

    private String value;

    public int getKey() {
        return key;
    }
    public String getValue() {
        return value;
    }
    YmArticleType(int key, String value) {
        this.key = key;
        this.value = value;
    }

    @Override
    public String toString() {
        return "YmArticleType{" +
                "key=" + key +
                ", value='" + value + '\'' +
                '}';
    }

    public static YmArticleType fromId(int key){
        switch (key){
            case 1:
                return HOTARTICLES;
            case 2:
                return FEATUREDARTICLES;
            case 3:
                return RECOMMENDEDARTICLES;
            case 4:
                return NEWEST;
            default:
                throw  new IllegalArgumentException();
        }

    }

}
